<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>扩展运算符</title>
</head>
<body>
  <ul>
    <li>Y</li>
    <li>Y</li>
    <li>D</li>
    <li>S</li>
  </ul>
  <script>
    /*
      扩展运算符: ...
      作用：
        1. 把伪数组转成真数组
        2. 合并数组/合并对象
        3. 复制数组/复制对象
    */
    // 1. 
    let liList = document.getElementsByTagName('li')
    console.log([...liList])

    let arr1 = [1, 2, 3]
    let arr2 = [4, 5, 6]
    let arr = [7, 8 ,9]
    console.log(arr1.concat(arr2))
    let arr3 = [...arr1, ...arr2, ...arr]
    console.log(arr3)
    let obj1 = {
      a: 1,
      b: 2
    }
    let obj2 = {
      c: 3,
      d: 4
    }
    let obj3 = {
      ...obj1,
      ...obj2
    }
    console.log(obj3)



    let arr4 = [1, 2, 3]
    // let arr5 = arr4// 叫不叫复制？
    let arr5 = [...arr4]
    arr5.push(99)
    console.log(arr4)

    let obj4 = {
      name: '小vue',
      age: 5
    }

    let obj5 = {
      ...obj4
    }
    // console.log(obj5)
    obj5.age = 4

    console.log(obj4)






  </script>
</body>
</html>